﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows;

namespace TaiwuZD
{
   
   

    /// <summary>
    /// id 对应文字
    /// </summary>
    //public static class TaiWuID
    //{

    //    private static Dictionary<int, string> Data { get; set; } = new Dictionary<int, string>();

    //    static TaiWuID()
    //    {
    //        Data=LoadResource<Dictionary<int, string>>("ID");            
    //    }

    //    /// <summary>
    //    /// 加载资源
    //    /// </summary>
    //    /// <typeparam name="T"></typeparam>
    //    /// <param name="propname"></param>
    //    /// <returns></returns>
    //    public static T LoadResource<T>(string propname)
    //    {
    //        var stream = Application.GetResourceStream(new Uri($"/json/{propname}.json", UriKind.Relative));

    //        if (stream != null && stream.Stream != null && stream.Stream.CanRead)
    //        {
    //            using (var sr = new StreamReader(stream.Stream))
    //            {
    //                var tmp = sr.ReadToEnd();
    //                return JsonConvert.DeserializeObject<T>(tmp);
    //            }
    //        }
    //        return default(T);
    //    }

    //    public static string GetTitle(int key)
    //    {
    //        return Data.ContainsKey(key) ? Data[key] : string.Empty;
    //    }
    //}

    /// <summary>
    /// 物品分类
    /// </summary>
    public enum TwItemType
    {
        [Description("全部")] All,
        /// <summary>
        /// 制造
        /// </summary>
        [Description("制造")] Manufacture,

        /// <summary>
        /// 丹药
        /// </summary>
        [Description("丹药")] Medicine,

        /// <summary>
        /// 食物
        /// </summary>
        [Description("食物")] Food,

        /// <summary>
        /// 装备
        /// </summary>
        [Description("装备")]Equipment,

        /// <summary>
        /// 书、图纸
        /// </summary>
        [Description("书籍")] Book,

        /// <summary>
        /// 其它
        /// </summary>
        [Description("其它")] Other
    }

    public struct TwItemType2 :IEquatable<TwItemType2>
    {
        [JsonIgnore]
        private int[] _Types;

        public int[] TypeIds
        {
            get { return _Types; }
            set { if (_Types == null) _Types = value; }
        }

        public int this[int id]
        {
            get { if (id >= 0 && id < 3) return TypeIds[id]; else return 0; }
        }
         
        public TwItemType2(int a,int b,int c)
        {
            _Types = new int[3];
            TypeIds[0] = a;
            TypeIds[1] = b;
            TypeIds[2] = c;
        }

        public override int GetHashCode()
        {
            return TypeIds[0].GetHashCode() ^ TypeIds[1].GetHashCode() ^ TypeIds[2].GetHashCode() ;
        }

        public bool Equals(TwItemType2 other)
        {
            return TypeIds[0] == other.TypeIds[0] && TypeIds[1] == other.TypeIds[1] && TypeIds[2] == other.TypeIds[2];
        }
    }

    public class TwItemTypes
    {
        public Dictionary<int, string>[] TypesData { get; set; } = new Dictionary<int, string>[3];

        public TwItemType2[] All { get; set; }

        [JsonIgnore]
        public int[] Marjor { get { return TypesData[0]?.Keys?.ToArray(); } }

         

    }
     
}
